package junit;

import instructions.Composition;
import instructions.Print;
import instructions.VariableAssign;
import values.Boolean;
import base.Identifier;
import base.Interpreter;
import expressions.*;

public class TestGate {

	/* 
	 * Logical Gates tests :
	 * 
	 * a = true;
	 * b = false;
	 * 
	 * print(!a);
	 * print(a && b);
	 * print(a || b);
	 * 
	 */
	
	public static void main(String[] args) {
		Identifier a = new Identifier("a");
		Identifier b = new Identifier("b");
		
		VariableAssign aVal = new VariableAssign(a, new Boolean(true));
		VariableAssign bVal = new VariableAssign(b, new Boolean(false));
		
		NotGate not = new NotGate(new VariableAccess(a));
		AndGate and = new AndGate(new VariableAccess(a), new VariableAccess(b));
		OrGate or = new OrGate(new VariableAccess(a), new VariableAccess(b));
		
		Print notPrint = new Print(not);
		Print andPrint = new Print(and);
		Print orPrint = new Print(or);
		
		System.out.println("Tests for logical gates : x = true, y = false");
		Composition compoVal = new Composition(aVal, bVal);
		System.out.println("Test 1 : !x");
		Composition compoNot = new Composition(compoVal, notPrint);
		System.out.println("Test 2 : x && y");
		Composition compoAnd = new Composition(compoNot, andPrint);
		System.out.println("Test 3 : x || y");
		Composition finalcompo = new Composition(compoAnd, orPrint);
		
		Interpreter.instr(finalcompo);
		
	}
	
}
